//
//  CustomerHeadView.m
//  mendianjieke
//
//  Created by 响当当 on 7/31/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "CustomerHeadView.h"

@interface CustomerHeadView()
@property (nonatomic, strong)UIImageView *headImageView;//头像
@property (nonatomic, strong)UILabel *genderLabrl;//性别
@property (nonatomic, strong)UILabel *ageLabel;//年龄
@property (nonatomic, strong)UILabel *vipLabel;//头像
@property (nonatomic, strong)UILabel *customerHOrderLabel;//最高客单
@property (nonatomic, strong)UILabel *customerLOrderLabel;//最低客单
@property (nonatomic, strong)UILabel *averageOrderLabel;//平均客单
@property (nonatomic, strong)UILabel *normalTimeLabel;//正常周期
@property (nonatomic, strong)UILabel *liveTimeLabel;//生命周期

@end

@implementation CustomerHeadView

- (UIImageView *)headImageView
{
    if (!_headImageView)
    {
        _headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,38*kUIScaleBasePlus,150*kUIScaleBasePlus,150*kUIScaleBasePlus)];
//        _headImageView.backgroundColor = [UIColor redColor];
        
    }
    return _headImageView;
}

- (UILabel *)genderLabrl
{
    if (!_genderLabrl)
    {
        _genderLabrl = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,15*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentLeft
                                         textClor:LCHexColor(0x282828)
                                         textFont:14*kUIScaleBasePlus];
        
    }
    return _genderLabrl;
}

- (UILabel *)ageLabel
{
    if (!_ageLabel)
    {
        _ageLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,CGRectGetMaxY(self.genderLabrl.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentLeft
                                         textClor:LCHexColor(0x282828)
                                         textFont:14*kUIScaleBasePlus];
        
    }
    return _ageLabel;
}

- (UILabel *)vipLabel
{
    if (!_vipLabel)
    {
        _vipLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,CGRectGetMaxY(self.ageLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentLeft
                                         textClor:LCHexColor(0x282828)
                                         textFont:14*kUIScaleBasePlus];
        
    }
    return _vipLabel;
}

- (UILabel *)customerHOrderLabel
{
    if (!_customerHOrderLabel)
    {
        _customerHOrderLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,CGRectGetMaxY(self.vipLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentLeft
                                         textClor:LCHexColor(0x282828)
                                         textFont:14*kUIScaleBasePlus];
        
    }
    return _customerHOrderLabel;
}

- (UILabel *)customerLOrderLabel
{
    if (!_customerLOrderLabel)
    {
        _customerLOrderLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,CGRectGetMaxY(self.customerHOrderLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentLeft
                                         textClor:LCHexColor(0x282828)
                                         textFont:14*kUIScaleBasePlus];
        
    }
    return _customerLOrderLabel;
}

- (UILabel *)averageOrderLabel
{
    if (!_averageOrderLabel)
    {
        _averageOrderLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,CGRectGetMaxY(self.customerLOrderLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentLeft
                                         textClor:LCHexColor(0x282828)
                                         textFont:14*kUIScaleBasePlus];
        
    }
    return _averageOrderLabel;
}

- (UILabel *)normalTimeLabel
{
    if (!_normalTimeLabel)
    {
        _normalTimeLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,CGRectGetMaxY(self.averageOrderLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                     textAligment:NSTextAlignmentLeft
                                         textClor:LCHexColor(0x282828)
                                         textFont:14*kUIScaleBasePlus];
        
    }
    return _normalTimeLabel;
}

- (UILabel *)liveTimeLabel
{
    if (!_liveTimeLabel)
    {
        _liveTimeLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.headImageView.frame)+15*kUIScaleBasePlus,CGRectGetMaxY(self.normalTimeLabel.frame)+5*kUIScaleBasePlus,200*kUIScaleBasePlus,20*kUIScaleBasePlus)
                                            textAligment:NSTextAlignmentLeft
                                                textClor:LCHexColor(0x282828)
                                                textFont:14*kUIScaleBasePlus];
        
    }
    return _liveTimeLabel;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self addSubview:self.headImageView];
        [self addSubview:self.genderLabrl];
        [self addSubview:self.ageLabel];
        [self addSubview:self.vipLabel];
        [self addSubview:self.customerHOrderLabel];
        [self addSubview:self.customerLOrderLabel];
        [self addSubview:self.averageOrderLabel];
        [self addSubview:self.normalTimeLabel];
        [self addSubview:self.liveTimeLabel];

        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,225*kUIScaleBasePlus,SCREEN_WIDTH,5*kUIScaleBasePlus)];
        lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [self addSubview:lineView];
    }
    return self;
}

- (void)getInfo:(NSArray *)arr headImage:(NSString *)photo
{
    self.genderLabrl.text = [NSString stringWithFormat:@"性别:%@",[arr[0] integerValue] == 0 ? @"女" : @"男"];
    self.ageLabel.text = [NSString stringWithFormat:@"年龄:%@",arr[1]];
    self.vipLabel.text = [NSString stringWithFormat:@"会员年龄:%@",arr[2]];
    self.customerHOrderLabel.text = [NSString stringWithFormat:@"最高客单:¥%@",arr[3]];
    self.customerLOrderLabel.text = [NSString stringWithFormat:@"最低客单:¥%@",arr[4]];
    self.averageOrderLabel.text = [NSString stringWithFormat:@"平均客单:¥%@",arr[5]];
    self.normalTimeLabel.text = [NSString stringWithFormat:@"正常周期:%@",arr[6]];
    self.liveTimeLabel.text = [NSString stringWithFormat:@"生命周期:%@",arr[7]];
    
    NSArray *arrs = [photo componentsSeparatedByString:@","];
    
    NSData *decodeData = [[NSData alloc]initWithBase64EncodedString:arrs[1] options:(NSDataBase64DecodingIgnoreUnknownCharacters)];
    self.headImageView.image = [UIImage imageWithData:decodeData];
}

@end
